import datetime


# def parse_minute(time: datetime.datetime):
#     if time is None:
#         return None
#     return (time.hour * 60 + time.minute + time.second / 60 + time.microsecond
#             / 60 / 1000000)

def parse_second(time: datetime.datetime):
    if time is None:
        return None
    return time.timestamp()

# def calculate_time_window(new_time_obj, solution_time):
#     # 计算时间窗口
#     begin_time = new_time_obj + datetime.timedelta(minutes=solution_time[0])
#     end_time = new_time_obj + datetime.timedelta(minutes=solution_time[1])
#     return begin_time, end_time


def calculate_time_window(solution_time):
    # 计算时间窗口
    begin_time = datetime.datetime.fromtimestamp(solution_time[0]).strftime('%Y-%m-%d %H:%M:%S')
    end_time = datetime.datetime.fromtimestamp(solution_time[1]).strftime('%Y-%m-%d %H:%M:%S')
    return begin_time, end_time
